home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Adobe Graphics & Publishing SDK 1996 December
/
Adobe Graphics & Publishing SDK 1996 December.iso
/
pc
/
pm65sdk
/
sourcecode
/
c_language
/
open
/
common
/
main.cpp
next >
Wrap
C/C++ Source or Header
|
1996-09-06
|
6KB
|
275 lines
/*
*--- main.cpp ----------------------------------------------------------
* Copyright (c) 1992-96 Adobe Systems, Inc. All rights reserved.
*
* PageMaker plug-in OpenCopy.
*-----------------------------------------------------------------------
*/
/* ---------------- PageMaker SDK include files ---------------- */
#include "PMPlugin.h"
#include "opencpy.h"
/* ---------------- Plug-in include files ---------------- */
#ifdef MACINTOSH
#include "WinTypes.h"
#endif // MACINTOSH
/* ---------------- Cross-platform include files ---------------- */
#include <string.h>
#include <stdio.h>
/* ---------------- Platform specific include files ---------------- */
#ifdef MACINTOSH
#include <types.h>
#ifndef powerc
#include <A4Stuff.h>
#include <SetUpA4.h>
#endif
#else
#include <windows.h>
#endif
/* ---------------- Type definitions ---------------- */
/* ---------------- Definitions ---------------- */
#define SUCCESS 1
#define FAILURE 0
#define STAYINMEMORY -1
#define BUG_IN_HEADER
/* ---------------- PageMaker (New)SDK include files ---------------- */
#include "CIInterfaceManager.h"
#include "PMEvent.h"
#include "PMEventRec.h"
#include "CIBasic.h"
#include "PMInterfaceIDs.h"
#include "CICommandsAndQueries.h"
/* ---------------- Function declarations ---------------- */
PMXErr DoInvoke( PMMessage *pMsg );
PMXErr DoLoad(PMMessage* pMsg);
PMXErr DoRegister(PMMessage* pMsg);
PMXErr DoInvoke(PMMessage* pMsg);
PMXErr DoEvent(PMMessage* pMsg);
PMXErr DoSysEvent(PMMessage* pMsg);
PMXErr DoAcquireInterface(PMMessage* pMsg);
PMXErr DoReleaseInterface( PMMessage *pMsg );
PMXErr DoUnload(PMMessage* pMsg);
PMXErr DoShutdown(PMMessage* pMsg);
PMXErr DoCleanup(PMMessage* pMsg);
#ifdef MACINTOSH
#ifdef powerc
#pragma export on
#endif
PMXErr main(PMMessage *pMsg);
#ifdef powerc
#pragma export off
#endif
#else
BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID pReserved);
#endif
/* ---------------- Globals ---------------- */
sPMParamBlockPtr thePB = NULL;
CIInterfaceManager *gpIntfMgr = (CIInterfaceManager *) NULL;
#ifdef WINDOWS
HINSTANCE ghDLL;
BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID pReserved)
{
ghDLL = hDLL;
return TRUE;
}
#endif
/*
*--- main --------------------------------------------------------------------
* Entry point for plug-in control tasks.
*-----------------------------------------------------------------------------
*/
PMXErr main(PMMessage *pMsg)
{
PMXErr result;
#if __MWERKS__ && __MC68K__
long oldA4 = SetCurrentA4();
RememberA4();
#endif
gpIntfMgr = pMsg->pInterfaceMgr;
switch ( pMsg->opCode ) {
case kPMLoad:
result = DoLoad(pMsg);
break;
case kPMRegister:
result = DoRegister(pMsg);
break;
case kPMInvoke:
result = DoInvoke(pMsg);
break;
case kPMEvent:
result = DoEvent(pMsg);
break;
case kPMSysEvent:
result = DoSysEvent(pMsg);
break;
case kPMAcquireInterface:
result = DoAcquireInterface(pMsg);
break;
case kPMReleaseInterface:
result = DoReleaseInterface(pMsg);
break;
case kPMUnload:
result = DoUnload(pMsg);
break;
case kPMShutdown:
result = DoShutdown(pMsg);
break;
case kPMCleanup:
result = DoCleanup(pMsg);
break;
default:
result = 0;
}
#if __MWERKS__ && __MC68K__
SetA4(oldA4);
#endif
return result;
}
PMXErr DoRegister( PMMessage *pMsg )
{
PMXErr result = SUCCESS;
CIBasic *pBasic;
gpIntfMgr = pMsg->pInterfaceMgr;
result = gpIntfMgr->AcquirePMInterface((DWORD)PMIID_BASIC,
(LPVOID *)&pBasic);
pBasic->RegisterPMEvent(PMEVT_MENUCOMMAND_BEFORE);
gpIntfMgr->ReleasePMInterface((LPVOID)pBasic);
onErr:
return result;
}
PMXErr DoAcquireInterface( PMMessage *pMsg )
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoReleaseInterface( PMMessage *pMsg )
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoInvoke( PMMessage *pMsg )
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoLoad(PMMessage* pMsg)
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoEvent(PMMessage* pMsg)
{
PMXErr result = SUCCESS;
PMEvent *pEvt;
pEvt = (PMEvent *)pMsg->pPMData;
PPMEVT_MENUCOMMAND_REC pMenu;
CICommandQuery *pCmdQry = (CICommandQuery *)NULL;
gpIntfMgr = pMsg->pInterfaceMgr;
if (pEvt->eventID == PMEVT_MENUCOMMAND_BEFORE) {
pMenu = (PPMEVT_MENUCOMMAND_REC)pEvt->lParm;
if ((pMenu->menuGroupID == 512) && (pMenu->menuItemID == 514))
{ //Open Menu Item
if (!gpIntfMgr->AcquirePMInterface(PMIID_CMDQRY, (LPVOID *)&pCmdQry))
pCmdQry->Retrieve (&thePB);
else
return CQ_FAILURE;
if (pEvt->wasHandled != TRUE)
OpenPubCopy();
gpIntfMgr->ReleasePMInterface((LPVOID *)pCmdQry);
pEvt->wasHandled = TRUE;
}
} else {
pEvt->wasHandled = FALSE;
}
return result;
}
PMXErr DoSysEvent(PMMessage* pMsg)
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoUnload(PMMessage* pMsg)
{
PMXErr result = STAYINMEMORY;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoShutdown(PMMessage* pMsg)
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}
PMXErr DoCleanup(PMMessage* pMsg)
{
PMXErr result = SUCCESS;
gpIntfMgr = pMsg->pInterfaceMgr;
return result;
}